import Main from '@/views/Main.vue';
import {loginRouter, preview, locking, page500, page403, page404} from '@/router/notMain';
import modules from './module';

/**
 * 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
 * @type {{path: string, name: string, component, children: Array}}
 * @private
 */
let _otherRouter = {
    path: '/',
    name: 'otherRouter',
    component: Main,
    children: []
};

_otherRouter.children.push({
    path: '/',
    title: {i18n: 'home'},
    name: 'home-index',
    component: resolve => { require(['@/views/system/home.vue'], resolve); }
});

/**
 * 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
 * @type {Array}
 */
let _appRouter = new Array();

/**
 * 添加组件案例模块
 */
for (let i in modules) {
    _otherRouter.children.push.apply(_otherRouter.children, modules[i].other_router);
    _appRouter.push.apply(_appRouter, modules[i].router);
}

export const otherRouter = _otherRouter;
export const appRouter = _appRouter;

/**
 * 所有上面定义的路由都要写在下面的routers里
 * @type {[null,null,null,null,null,null,null,null]}
 */
export const routers = [
    ...appRouter,
    otherRouter,
    loginRouter,
    preview,
    locking,
    page500,
    page403,
    page404
];
